#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N=4e5+10;
int f[20][N];
int ans[N];
struct node 
{
    ll x, y;
    int id;
    bool operator<(const node& other) const {
        return x < other.x;
    }
}a[N];


int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].x>>a[i].y;
		if(a[i].y<a[i].x)
		{
			a[i].y+=m;
		}
		a[i].id=i;
		a[i+n].x=a[i].x+m;
		a[i+n].y=a[i].y+m;
	}
	
    sort(a+1,a+1+2*n);
    
    for(int i=1,j=1;i<=2*n;i++)
	{
		while(j<=2*n && a[i].y>=a[j].x)
		{
			f[0][i]=j;
			j++;
		}
		j--;
//		cout<<f[0][i]<<endl;
	}

	for(int i=1;i<=19;i++)
	{
		for(int j=1;j<2*n;j++)
		{
			f[i][j]=f[i-1][f[i-1][j]];
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		int beg=i;
		int cnt=2;
		for(int j=19;j>=0;j--)
		{
			if(f[j][beg] && a[f[j][beg]].y<a[i].x+m)
			{
				beg=f[j][beg];
				cnt+=(1<<j);
			} 
		}
		ans[a[i].id]=cnt;
	}
	
    for(int i=1;i<=n;i++) cout<<ans[i]<<' ';
	
	return 0;
}

